/*
 * @Author: wanglidong
 * @Date: 2022-02-11 11:27:43
 * @LastEditors: wanglidong
 * @LastEditTime: 2022-02-11 11:27:46
 * @Description: 开始你的表演
 * @FilePath: \lowcode-front\src\utils\filter.js
 */
export function moneyFilter(value) {
  try {
    let before = value.toFixed(2)
    before = before.toString()
    let num = before.split('.')[0]
    let numSmall = before.split('.')[1]
    let result = [], counter = 0;
    num = (num || 0).toString().split('');
    for (let i = num.length - 1; i >= 0; i--) {
      counter++;
      result.unshift(num[i]);
      if (!(counter % 3) && i != 0) {
        result.unshift(',');
      }
    }
    let after = numSmall === undefined ? result.join('') : result.join('') + '.' + numSmall
    return after
  } catch (e) {
    return ""
  }
}
